package com.xishu.entity.shop;

import com.xishu.annotation.dao.Search;
import com.xishu.entity.AbstractEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
import java.util.Objects;

/**
 * 报表里面的查询字段
 */
@Entity(name = "shop_search_item")
@Table(indexes = {@Index(columnList = "companyId"), @Index(columnList = "shopId")})
@Data
public class ShopSearchItem extends AbstractEntity {
    private static final long serialVersionUID = -3542354528592856520L;

    @ApiModelProperty(value = "归属的餐厅公司")
    private Long companyId;

    @ApiModelProperty(value = "归属的分店")
    private Long shopId;

    @ApiModelProperty(value = "归属的分店")
    @Search(in = true, fieldName = "shopId")
    @Transient
    private List<Long> shopIdList;

    @ApiModelProperty(value = "中文名称")
    private String name_zh;

    @ApiModelProperty(value = "英文名称")
    private String name_en;

    @ApiModelProperty(value = "1菜品，2品类，3支付方式，4服务员，5删除菜品")
    private Integer type;

    public ShopSearchItem(Long companyId, Long shopId, String name_zh, String name_en, Integer type) {
        this.companyId = companyId;
        this.shopId = shopId;
        this.name_zh = name_zh;
        this.name_en = name_en;
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShopSearchItem that = (ShopSearchItem) o;
        return Objects.equals(getShopId(), that.getShopId()) && Objects.equals(getName_zh(), that.getName_zh()) && Objects.equals(getName_en(), that.getName_en()) && Objects.equals(getType(), that.getType());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getShopId(), getName_zh(), getName_en(), getType());
    }

    public ShopSearchItem() {
    }
}
